--
-- Author: shunguo.chen
-- Date: 2016-10-19 17:42:49
--
-- RewardMemberPanel

local ClassRef = app.mvc.createPanelClass(...)

function ClassRef.create(data, node)
	local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.RewardMemberPanel))
	if node == nil then
		ccui.Helper:doLayout(sprite)
	end
	sprite:init(data)
	return sprite
end                    

function ClassRef:init(data)
	self.super.init(self, data)

	local con = self._ui["Panel/bom/01Button"]
	con:setVisible(app:getInst("PayModel") ~= nil)
	con:findChild("01Button"):addClickEventListener(function()
			executeFunc(self._onOperate, "payMember")
		end)

	local con = self._ui["Panel/bom/02Button"]
	con:findChild("01Button"):addClickEventListener(function()
			executeFunc(self._onOperate, "buyMember")
		end)

	con:findChild("02Gold/01Icon"):loadTexture(self._data.moneyIcon)
	con:findChild("02Gold/02Num"):setString(self._data.moneyCost)

	self._ui.image:loadTexture(self._data.image)
end

function ClassRef:onOperate(cb)
	self._onOperate = cb
end

function ClassRef:setMemberDay(num)
	self._ui.num:setString(num)
end

return ClassRef